package com.qiyun.dinghuohui.utils;

import com.qiyun.dinghuohui.common.CommonDataSets;
import com.qiyun.dinghuohui.vo.MyOrderData;

import java.util.Comparator;

public class DDMX_PAIXU implements Comparator<MyOrderData> {

	private int px_flag = 0;

	public DDMX_PAIXU() {
	};

	public DDMX_PAIXU(int px_flag) {
		this.px_flag = px_flag;
	}

	@Override
	public int compare(MyOrderData lhs, MyOrderData rhs) {
		try
		{
			switch (px_flag)
			{
			case 0:
				int code1 = CommonDataSets.getIntforString(lhs.getCode());
				int code2 = CommonDataSets.getIntforString(rhs.getCode());
				if (code1 > code2)
				{
					return 1;
				} else if (code1 < code2)
				{
					return -1;
				} else
				{
					return 0;
				}
			case 1:
				int num1 = CommonDataSets.getIntforString(lhs.getSum());
				int num2 = CommonDataSets.getIntforString(rhs.getSum());
				if (num1 > num2)
				{
					return -1;
				} else if (num1 < num2)
				{
					return 1;
				} else
				{
					return 0;
				}
			default:
				break;
			}
		} catch (Exception e)
		{
			// TODO: handle exception
		}
		return 0;
	}

}
